﻿function TraceUtils(){
}

TraceUtils.prototype.traceString = function(obj, var_name, tabCount, st){
	var str=st;
	for(var i=0;i<tabCount;i++) str+="\t";
	str+=var_name+":";
	if(tabCount>5) return (str+" ###Recursion exceeds max limit\n");
	switch(typeof(obj)){
		case "string":
			str+=" \""+obj+"\"\n";
		break;
		case "number":
			str+=" "+obj+"\n";
		break;
		case "boolean":
			str+=" "+obj+"\n";
		break;
		case "function":
			str+=" #FUNCTION\n";
		break;
		case "object":
			if(obj == null) {
        return str += ("#BAD OBJECT: " + obj);
			}
			if(obj.length==undefined){
				str+=" #Object:\n";
				for(var key in obj){
					str+=this.traceString(obj[key],key,tabCount+1,st);
				}
			}
			else{
				str+=" #Array:\n";
				for(var j=0;j<obj.length;j++){
					str+=this.traceString(obj[j],"["+j+"]",tabCount+1,st);
				}
			}
			
		break;
		case "array":
			// does not return array;
		break;
		default:
			str+=" #UKNOWN OBJECT TYPE ("+typeof(obj)+")\n";
		break;
	}
	return str;
}
